package com.headline.common;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * Created with Administrator
 * DATE:2016/11/8
 * Time:10:54
 */
public class Log {
    public Logger logger = null;
    private static Log log;

    private Log() {
        String filePath = this.getClass().getResource("/").getPath();
        filePath = filePath.substring(1).replace("bin", "src");
        logger = Logger.getLogger(this.getClass());
        PropertyConfigurator.configure(filePath + "log4j.properties");
    }

    public static Log getLogger() {
        if (log != null) {
            return log;
        } else {
            return new Log();
        }
    }
}
